package com.pass.util;

import static android.content.Context.MODE_PRIVATE;

import android.content.Context;
import android.content.SharedPreferences;

import java.io.File;

public class PreferenceUtil {
    public static void saveString(Context context, String fileName, String keyStr, String valueStr) {
        SharedPreferences sp = context.getSharedPreferences(fileName, MODE_PRIVATE);
        sp.edit().putString(keyStr, valueStr).apply();
    }

    public static void saveInt(Context context, String fileName, String keyStr, int valueStr) {
        SharedPreferences sp = context.getSharedPreferences(fileName, MODE_PRIVATE);
        sp.edit().putInt(keyStr, valueStr).apply();
    }

    public static String getString(Context context, String fileName, String keyStr) {
        SharedPreferences sp = context.getSharedPreferences(fileName, MODE_PRIVATE);
        return sp.getString(keyStr, "");
    }
    public static int getInt(Context context, String fileName, String keyStr) {
        SharedPreferences sp = context.getSharedPreferences(fileName, MODE_PRIVATE);
        return sp.getInt(keyStr, 0);
    }

    public static String getString(Context context, String fileName, String keyStr, String defaultValue) {
        SharedPreferences sp = context.getSharedPreferences(fileName, MODE_PRIVATE);
        return sp.getString(keyStr, defaultValue);
    }
}
